package com.ming.interview;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @Description 打印杨辉三角
 * @Author ye.ming
 * @Date Created in 2019/8/26
 */
public class Main24_1 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入要打印的杨辉三角的行数:");
        int n = sc.nextInt();
        System.out.println("[1]");
        m1(new int[]{1}, n);
        sc.close();

    }


    private static void m1(int[] m, int n) {
        int[] next = new int[m.length + 1];
        if (m.length + 1 > n) {
            return;
        }
        for (int i = 0; i < next.length; i++) {
            if (i == 0) {
                next[i] = m[i];
            } else if (i == m.length) {
                next[i] = m[i - 1];
            } else {
                next[i] = m[i - 1] + m[i];
            }
        }
        System.out.println(Arrays.toString(next));
        m1(next, n);
    }


}
